home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 1.2 KB | 48 lines | [TEXT/ttxt] |
- --<<<
-
- in module WebImplementation
-
- global fileMIMETypes := new hashTable
-
- function getFileMIMEType suffix -> (
- local type := fileMIMETypes[getlowercase(suffix as string)]
- if type == empty do
- report (new generalexception) #("no mime type for file suffix", suffix)
- type
- )
-
- fileMIMETypes["htm" as string] := "text/html" as string
- fileMIMETypes["html" as string] := "text/html" as string
- fileMIMETypes["sxt" as string] := "application/x-scriptx-title" as string
- fileMIMETypes["gif" as string] := "image/gif" as string
-
- function getfilemethod url -> (
- local file := url.path
- local dirs := new Array
- local n;
- local slash := "/"[1]
-
- if ((size file) > 0 and file[1] = slash) do
- file := copyFromTo file 1 (size file)
-
- repeat while (n := getOrdOne file slash) > 0 do (
- append dirs (copyFromTo file 0 (n - 1))
- file := copyFromTo file n (size file)
- )
-
- local suffix := file
-
- repeat while (n := getOrdOne suffix "."[1]) > 0 do (
- suffix := copyFromTo suffix n (size suffix)
- )
-
- local info := new hashtable
- info["content-type" as string] := getFileMIMEType suffix
-
- #(info, getstream (spawn therootdir dirs) file @readable)
- )
-
- registerAccessMethod WebAccessManager "file" getfilemethod
-
- -->>>
-